package com.intelli4.pos.ui;

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.intelli4.pos.controllers.SessionController;

public class CashierFrame extends JFrame {
	private static final long serialVersionUID = 5148875761100424029L;

	private SessionController sessionController;

	private MenuPanel menuPanel;
	private OrderPanel orderPanel;
	private NumberPadPanel numberPadPanel;

	public CashierFrame() {
		super();

		init();
	}

	public void setSessionController(SessionController sessionController) {
		this.sessionController = sessionController;
	}

	protected void init() {
		setLayout(new BorderLayout());

		menuPanel = new MenuPanel();
		orderPanel = new OrderPanel();
		numberPadPanel = new NumberPadPanel();

		JPanel leftPanel = new JPanel(new BorderLayout(5, 5));
		leftPanel.add(numberPadPanel, BorderLayout.NORTH);
		leftPanel.add(orderPanel, BorderLayout.CENTER);

		add(menuPanel, BorderLayout.CENTER);
		add(leftPanel, BorderLayout.WEST);

		addWindowListener(new WindowAdapter() {

			@Override
			public void windowClosed(WindowEvent e) {
				sessionController.closeCurrentSession();
				super.windowClosed(e);
			}

		});
	}

	public static void main(String[] args) {
		CashierFrame frame = new CashierFrame();
		frame.setSize(1024, 768);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
}
